using UnityEngine;

public class Grenade : Bullet
{
	[SerializeField]
	private int bounceCount;

	[SerializeField]
	private Explosion explode;

	protected override void FixedUpdate()
	{
	}

	protected override void OnCollisionEnter(Collision collision)
	{
		if (collision.gameObject.CompareTag("KillOnTouch"))
		{
			UnityEngine.Object.Destroy(base.gameObject);
			return;
		}
		bounceCount--;
		if ((bool)collision.rigidbody)
		{
			Rigidbody rigidbody = collision.rigidbody;
			CharacterPart component = rigidbody.GetComponent<CharacterPart>();
			BombCrate component2 = rigidbody.GetComponent<BombCrate>();
			if (component != null)
			{
				Boom();
			}
			else if (component2 != null)
			{
				component2.Blow(shooter);
			}
		}
		else if (bounceCount <= 0)
		{
			Boom();
		}
	}

	private void Boom()
	{
		explode.SetDamager(shooter, damage);
		explode.transform.parent = null;
		explode.Explode();
		UnityEngine.Object.Destroy(explode.gameObject, 4f);
		UnityEngine.Object.Destroy(base.gameObject);
	}
}
